package com.twu.biblioteca;

public class MainMenuState implements State {

    public static MainMenuState instance = new MainMenuState();
    String[] options = {"1. List Books", "2. Exit"};

    private MainMenuState(){}

    @Override
    public String[] getOptions() {
        return options;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public State act(String input) {

        int choice = Integer.parseInt(input);
        if(choice == 1){
            return LibraryMenuState.instance;
        }
        return null;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public boolean isValidInput(String input) {
        try {
            Integer choice = Integer.parseInt(input);
            return ((choice > 0) && (options.length > choice - 1));
        }
        catch (Exception e) {
            return false;
        }
    }
}
